<template>
  <div>
    <h5 class="mb-2" style="color: white; font-size: larger">图书管理系统</h5>
    <Menu active-name="0" theme="dark" @on-open-change="handleOpen" @on-select="handleSelect" accordion>
      <MenuItem name="1">
        <span>登录</span>
      </MenuItem>
      <MenuItem name="2">
        <span>注册</span>
      </MenuItem>
    </Menu>
  </div>
</template>

<script setup>
import { useRouter } from "vue-router";

const router = useRouter();

// 处理菜单项选择
const handleSelect = (name) => {
  console.log(name); // 打印选择的项进行调试
  if (name === "1") {
    // 跳转到登录页面
    router.push({ name: "login" }).catch((err) => {
      console.error(err);
    });
  } else if (name === "2") {
    // 跳转到注册页面
    router.push({ name: "register" }).catch((err) => {
      console.error(err);
    });
  }
};
</script>
